package com.jianbing.shasha.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.jianbing.common.annotation.Log;
import com.jianbing.common.core.controller.BaseController;
import com.jianbing.common.core.domain.AjaxResult;
import com.jianbing.common.enums.BusinessType;
import com.jianbing.shasha.domain.ShashaQuesMusic;
import com.jianbing.shasha.service.IShashaQuesMusicService;
import com.jianbing.common.utils.poi.ExcelUtil;
import com.jianbing.common.core.page.TableDataInfo;

/**
 * shasha项目音乐相关Controller
 * 
 * @author zjw
 * @date 2024-06-20
 */
@RestController
@RequestMapping("/shasha/music")
public class ShashaQuesMusicController extends BaseController
{
    @Autowired
    private IShashaQuesMusicService shashaQuesMusicService;

    /**
     * 查询shasha项目音乐相关列表
     */
    //   @PreAuthorize("@ss.hasPermi('shasha:music:list')")
    @GetMapping("/list")
    public TableDataInfo list(ShashaQuesMusic shashaQuesMusic)
    {
        startPage();
        List<ShashaQuesMusic> list = shashaQuesMusicService.selectShashaQuesMusicList(shashaQuesMusic);
        return getDataTable(list);
    }

    /**
     * 导出shasha项目音乐相关列表
     */
//     @PreAuthorize("@ss.hasPermi('shasha:music:export')")
    @Log(title = "shasha项目音乐相关", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ShashaQuesMusic shashaQuesMusic)
    {
        List<ShashaQuesMusic> list = shashaQuesMusicService.selectShashaQuesMusicList(shashaQuesMusic);
        ExcelUtil<ShashaQuesMusic> util = new ExcelUtil<ShashaQuesMusic>(ShashaQuesMusic.class);
        util.exportExcel(response, list, "shasha项目音乐相关数据");
    }

    /**
     * 获取shasha项目音乐相关详细信息
     */
    //   @PreAuthorize("@ss.hasPermi('shasha:music:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(shashaQuesMusicService.selectShashaQuesMusicById(id));
    }

    /**
     * 新增shasha项目音乐相关
     */
    //   @PreAuthorize("@ss.hasPermi('shasha:music:add')")
    @Log(title = "shasha项目音乐相关", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ShashaQuesMusic shashaQuesMusic)
    {
        return toAjax(shashaQuesMusicService.insertShashaQuesMusic(shashaQuesMusic));
    }

    /**
     * 修改shasha项目音乐相关
     */
    //  @PreAuthorize("@ss.hasPermi('shasha:music:edit')")
    @Log(title = "shasha项目音乐相关", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ShashaQuesMusic shashaQuesMusic)
    {
        return toAjax(shashaQuesMusicService.updateShashaQuesMusic(shashaQuesMusic));
    }

    /**
     * 删除shasha项目音乐相关
     */
    //   @PreAuthorize("@ss.hasPermi('shasha:music:remove')")
    @Log(title = "shasha项目音乐相关", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(shashaQuesMusicService.deleteShashaQuesMusicByIds(ids));
    }
}
